package com.kunteng.ynhxksh.controller;

import com.kunteng.ynhxksh.service.JYGKService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created By ShiYun with IntelliJ IDEA on 2018/4/2 10:28
 *
 * @author: ShiYun
 * @Email: 515867726@qq.com
 * @Date: 2018/4/2
 * To change this template use File | Settings | File Templates.
 */
@Api(tags = "交易管控接口")
@RestController
@RequestMapping("/jygk")
public class JYGKController {

    Logger logger = LoggerFactory.getLogger(JYGKController.class);

    @Autowired
    private JYGKService jygkService;

    @ApiOperation(value = "单笔交易金额分布", notes = "返回区间交易笔数分布统计数据")
    @RequestMapping(value = "/findJYCountsByJEQJ", method = RequestMethod.GET)
    public JSONArray findJYCountsByJEQJ() {
        logger.info("findJYCountsByJEQJ");
        Map map = jygkService.getJeRange();
        JSONArray jsonArray = JSONArray.fromObject(map);
        return jsonArray;
    }


    @ApiOperation(value = "典型交易样本数据", notes = "返回符合区间的最近最近一条交易记录")
    @RequestMapping(value = "/findJYInfosByJEQJ", method = RequestMethod.GET)
    public JSONArray findJYInfosByJEQJ() {
        logger.info("findJYInfosByJEQJ");
        List<Map> mapList = jygkService.getDXInfo();
        JSONArray jsonArray = JSONArray.fromObject(mapList);
        return jsonArray;
    }

    @ApiOperation(value = "实时交易记录", notes = "返回实时交易记录信息")
    @RequestMapping(value = "/findJYInfos", method = RequestMethod.GET)
    public JSONArray findJYInfos() {
        logger.info("findJYInfos");
        List<Map> mapList = jygkService.getTimeInfo();
        JSONArray jsonArray = JSONArray.fromObject(mapList);
        return jsonArray;
    }

    //    @ApiOperation(value = "交易管控", notes = "交易管控当天信息")
//    @RequestMapping(value = "/jygk", method = RequestMethod.GET)
//    public String jygk() {
//        Map map = jygkService.getDayJYGK();
//        Map area = (Map) map.get("area");
//        System.out.println("dxJY======dxJY");
//        if (map.get("dxOne") != null) {
//            Map dxOne = (Map) map.get("dxOne");
//            out(dxOne);
//        }
//        if (map.get("dxTwo") != null) {
//            Map dxTwo = (Map) map.get("dxTwo");
//            out(dxTwo);
//        }
//        if (map.get("dxThree") != null) {
//            Map dxThree = (Map) map.get("dxThree");
//            out(dxThree);
//        }
//        if (map.get("dxFour") != null) {
//            Map dxFour = (Map) map.get("dxFour");
//            out(dxFour);
//        }
//        if (map.get("dxFive") != null) {
//            Map dxFive = (Map) map.get("dxFive");
//            out(dxFive);
//        }
//        System.out.println("timeInfo======timeInfo");
//        List<Map> timeInfo = (List<Map>) map.get("timeInfo");
//        System.out.println("timeInfo.size()==" + timeInfo.size());
//        for (Map time : timeInfo) {
//            out(time);
//        }
//        return "area.toString()";
//    }
//
//    public static void out(Map map) {
//        System.out.println("jyje=" + String.valueOf(map.get("jyje")) + " jyxm=" + String.valueOf(map.get("jyxm"))
//                + " jysj=" + String.valueOf(map.get("jysj")) + " hymc=" + String.valueOf(map.get("hymc"))
//                + " xfmc=" + String.valueOf(map.get("xfmc")));
//    }

}
